package github.sf.fw.tools.db.model;

import java.util.ArrayList;
import java.util.Collection;

public class ResultRow extends ArrayList<ResultData> {

    private static final long serialVersionUID = 3356893512493024301L;

    public ResultRow(int initialCapacity) {
        super(initialCapacity);
    }

    public ResultRow() {
        super();
    }

    public ResultRow(Collection<? extends ResultData> c) {
        super(c);
    }

    public Object getValue(String columnName) {
        if (!isEmpty()) {
            for (ResultData resultDatum : this) {
                if (resultDatum.getColumnName().equals(columnName)) {
                    return resultDatum.getColumnValue();
                }
            }
        }
        return null;
    }

    public void showSelf() {
        if (!isEmpty()) {
            for (ResultData resultDatum : this) {
                System.out.printf("%s\t%s\t%s | ", resultDatum.getColumnName(), resultDatum.getColumnValue(), resultDatum.getColumnType());
            }
        }
        System.out.println();
    }
}
